<?php
class sfWidgetFormKTDTextarea extends sfWidgetForm{
    public function configure($options = array(), $attributes = array()){
        $this->addOption('hrp_mode', false);
        $this->addOption('preview', false);
    }
    public function render($name, $value = null, $attributes = array(), $errors = array()){
        $response = sfContext::getInstance()->getResponse();
        
        $response->addJavascript( '/js/markitup/jquery.markitup.js' );
        $response->addJavascript( '/js/markitup/sets/ktdcode/set.js');

        $response->addStylesheet('/js/markitup/skins/simple/style.css');
        $response->addStylesheet('/js/markitup/sets/ktdcode/style.css');
        

        $settings = $this->getOption('hrp_mode') ? 'myHRPKTDCodeSettings' : 'myKTDCodeSettings';

        $generateId = $this->generateId($name);
        $js = "<script language=\"javascript\">
                $(document).ready(function()	{
                    $('#".$generateId."').markItUp(".$settings.");
                    });
                </script>";
        
        $out = $js;
        $out .= $this->renderContentTag("textarea", $value, array_merge(array('name' => $name), $attributes));

        return $out;
    }
}
?>
